﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.IService.System;
using SmartAnswerPlatform.Models.Entitys.System;
using SmartAnswerPlatform.Models.RequestModels;
using SmartAnswerPlatform.Models.ViewModels.System;

namespace SmartAnswerPlatform.WebApi.Controllers.System
{
    [Route("roleMenu")]
    public class SysRoleMenuController : BaseController
    {
        private readonly ISysRoleMenuService _sysRoleMenuService;

        public SysRoleMenuController(ISysRoleMenuService sysRoleMenuService)
        {
            _sysRoleMenuService = sysRoleMenuService;
        }

        [HttpPost("findAll")]
        public async Task<ActionResult> FindAll()
        {
            return Success(await _sysRoleMenuService.FindAll());
        }

        [HttpPost("add")]
        public async Task<ActionResult> Add([FromBody] SysRoleMenuViewModel roleMenuViewModel)
        {
            return Success(await _sysRoleMenuService.Insert(roleMenuViewModel));
        }

        [HttpPost("update")]
        public async Task<ActionResult> update([FromBody] SysRoleMenuViewModel roleMenuViewModel)
        {
            return Success(await _sysRoleMenuService.Update(roleMenuViewModel));
        }

        [HttpPost("delete")]
        public async Task<ActionResult> delete([FromBody] IdRequestModels idRequest)
        {
            return Success(await _sysRoleMenuService.Delete(idRequest.Id));
        }
    }
}
